<html>
<head><meta charset="utf-8"><title>Getting the type of a QPath · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Getting.20the.20type.20of.20a.20QPath.html">Getting the type of a QPath</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="221300084"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Getting%20the%20type%20of%20a%20QPath/near/221300084" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caden Haustein <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Getting.20the.20type.20of.20a.20QPath.html#221300084">(Dec 31 2020 at 16:23)</a>:</h4>
<p>Is there any way to get the type of a <code>QPath</code> (I also have a <code>LateContext</code>). I'm trying to check if for a particular <code>QPath</code> the type is Slice(Char). Thanks!</p>



<a name="221300166"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Getting%20the%20type%20of%20a%20QPath/near/221300166" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Getting.20the.20type.20of.20a.20QPath.html#221300166">(Dec 31 2020 at 16:24)</a>:</h4>
<p><a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TypeckResults.html#method.qpath_res">https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TypeckResults.html#method.qpath_res</a> maybe? and then call <code>tcx.type_of(def_id)</code></p>



<a name="221320617"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Getting%20the%20type%20of%20a%20QPath/near/221320617" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Getting.20the.20type.20of.20a.20QPath.html#221320617">(Dec 31 2020 at 22:11)</a>:</h4>
<p>and then you can chain in <code>is_str()</code> <span aria-label="grinning" class="emoji emoji-1f600" role="img" title="grinning">:grinning:</span></p>



<a name="221320747"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Getting%20the%20type%20of%20a%20QPath/near/221320747" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Getting.20the.20type.20of.20a.20QPath.html#221320747">(Dec 31 2020 at 22:13)</a>:</h4>
<p><span class="user-mention" data-user-id="281950">@Aman Arora</span> &amp;str is different from &amp;[char]</p>



<a name="221320756"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Getting%20the%20type%20of%20a%20QPath/near/221320756" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Getting.20the.20type.20of.20a.20QPath.html#221320756">(Dec 31 2020 at 22:13)</a>:</h4>
<p>char is 32-bits, &amp;str is utf-8 encoded</p>



<a name="221320822"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Getting%20the%20type%20of%20a%20QPath/near/221320822" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Getting.20the.20type.20of.20a.20QPath.html#221320822">(Dec 31 2020 at 22:14)</a>:</h4>
<p>ah my bad sorry</p>



<a name="221320842"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Getting%20the%20type%20of%20a%20QPath/near/221320842" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aman Arora <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Getting.20the.20type.20of.20a.20QPath.html#221320842">(Dec 31 2020 at 22:14)</a>:</h4>
<p>Regardless there are a bunch of <code>is_</code> functions in <code>Ty</code> that might be useful <span aria-label="smile" class="emoji emoji-1f642" role="img" title="smile">:smile:</span></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>